package base.day12;

import java.util.Scanner;

public class StringEquals {
    public static void main(String[] args) {
        //已知的用户名和密码
        String name="zhangsan";
        String pass="111";
        for (int i = 1;i<4 ; i++) {
            Scanner sc=new Scanner(System.in);
            System.out.println("请输入用户名：");
            String username=sc.nextLine();
            System.out.println("请输入密码：");
            String password=sc.nextLine();

            if (username.equals(name)&& password.equals(pass)){
                System.out.println("登录成功");
                break;
            }
            if (username.length()>9||username.length()<3){
                System.out.println("请输入3-9个字符的用户名");
                continue;
            }
            else {
                if (i==3){
                    System.out.println("次数已用完，下次再来");
                    break;
                }else {
                    System.out.println("用户名或密码错误,还剩"+(3-i)+"次机会");
                    continue;
                }
            }
        }
    }
}
